package list.medium;

import list.ListNode;

import java.util.List;


/**
 * 反转链表
 * 输入：head = [1,2,3,4,5], left = 2, right = 4
 * 输出：[1,4,3,2,5]
 * 示例 2：
 * 输入：head = [5], left = 1, right = 1
 * 输出：[5]
 * 链接：https://leetcode-cn.com/problems/reverse-linked-list-ii
 */
public class ReverseLinkedListII_92 {
    public ListNode reverseBetween(ListNode head, int left, int right) {
        ListNode dummyHead = new ListNode();
        dummyHead.next = head;

        ListNode g = dummyHead;
        ListNode p = dummyHead.next;

        for (int i = 1; i < left; i++) {
            g = g.next;
            p = p.next;
        }

        for (int i = left; i < right; i++){
            ListNode l = p.next;
        }
        return dummyHead;
    }


}
